import requests


def get_city_code(city: str):
    # 使用高德地图 API 获取天气信息
    api_key = '89ea581769e3e599f0ca4b41a95ed132'  # 请替换为你的高德地图 API 密钥
    url = f'https://restapi.amap.com/v3/geocode/geo?address={city}&key={api_key}'
    response = requests.get(url)
    data = response.json()
    print(data)
    # 解析城市信息
    adcode=data['geocodes'][0]['adcode']

    # 返回格式化的天气信息
    return f"城市：{city}\n城市地区码为：{adcode}"


# 使用示例
# city = '110101'
# weather_info = get_weather(city)
# print(weather_info)
